package com.xiyu.service.controller.admin.health;
import com.xiyu.service.vo.health.medicineStock.MedicineStockAdjustInput;
import com.xiyu.service.vo.health.medicineStock.MedicineStockPageQueryOutput;
import com.xiyu.service.vo.health.medicineStock.MedicineStockPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.health.MedicineStockService;

@Tag(name = "药品库存")
@RestController
@RequestMapping("/health/medicine-stock")
@Validated
public class MedicineStockController {

    @Resource
    private MedicineStockService medicineStockService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询")
    @PreAuthorize("@ss.hasPermission('health:medicineStock:query')")
    public CommonResult<PageResult<MedicineStockPageQueryOutput>> pageQuery(@Valid MedicineStockPageQueryInput inputVO) {
        return success(medicineStockService.pageQuery(inputVO));
    }

    @PostMapping("/adjust")
    @Operation(summary = "数量校正")
    @PreAuthorize("@ss.hasPermission('health:medicineStock:adjust')")
    public CommonResult<Boolean> adjust(@Valid @RequestBody MedicineStockAdjustInput inputVO) {
        return success(medicineStockService.adjust(inputVO));
    }

    @PostMapping("/refund")
    @Operation(summary = "退缴")
    @PreAuthorize("@ss.hasPermission('health:medicineStock:refund')")
    @Parameter(name = "id", description = "药品库存主键ID", example = "")
    public CommonResult<Boolean> refund(@RequestParam("id") Long id) {
        return success(medicineStockService.refund(id));
    }

}
